package com.gopay.common.domain.rcs.req;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.gopay.common.constants.rcs.TranDirection;
import com.gopay.common.constants.txncd.IntTxnCd;
import com.gopay.common.domain.BaseEntity;
import com.gopay.common.domain.acps.AcctProd;
import com.gopay.common.domain.solution.TranLimitRes;
import com.gopay.common.util.NumberUtils;

/**
 * 额度校验请求
 * @RcsTransLimitRequest.java
 * @author liujy
 * @2013-7-22 下午1:50:05  www.gopay.com.cn Inc.All rights reserved.
 */
public class RcsTransLimitRequest extends BaseEntity{

    private static final long serialVersionUID = 1L;
    
    public static enum RequestType{
        check,// 只校验不更新
        checkAndAdd,// 校验且累计增加
        subtract,// 不校验回滚累计
        subtract_not_times_limit,// 不校验回滚非次数累计
        add;// 累计增加
    }
    
    /** 客户ID */
    private String custId;
    /** 账户产品 */
    private AcctProd acctProd;
    /** 内部交易码 */
    private IntTxnCd intTxnCd;
    /** 资金方向 */
    private TranDirection tranDirection;
    /** 金额  */
    private List<BigDecimal> tranAmts;
    /** 日期(订单未保存时取当前自然日期)，格式：yyyyMMdd */
    private String transDate;
    /** 国付宝订单号 */
    private String gopayOrderId;
    /** 风控请求类型(保存订单前使用check) */
    private RequestType requestType;
    
    /** 客户交易额度配置 */
    private TranLimitRes custTranLimitConf;
    
    /** 以下参数付款到银行使用 */
    /** 收款人央行银行代码 */
    private String pbocBankCode;
    /** 收款人银行名称 */
    private String bankName;
    /** 收款人银行账号 */
    private String bankAcctNum;
    /** 收款人银行账户开户名 */
    private String bankAcctName;
    
    
    public int getTotalNum(){
    	return null == tranAmts ? 0 : tranAmts.size();
    }
    
    public BigDecimal getTotalAmt(){
    	BigDecimal totalAmt = NumberUtils.getZero();
    	if(0 == getTotalNum()){
    		return totalAmt;
    	}
    	for(int i = 0, size = tranAmts.size(); i < size; i++){
    		totalAmt = totalAmt.add(tranAmts.get(i));
    	}
    	return totalAmt;
    }
    
    public void setTranAmts(BigDecimal tranAmt) {
    	tranAmts = new ArrayList<BigDecimal>();
    	tranAmts.add(tranAmt);
    }
    
	public void setTranAmts(List<BigDecimal> tranAmts) {
		this.tranAmts = tranAmts;
	}
	
	public List<BigDecimal> getTranAmts() {
		return tranAmts;
	}
	
	
	
	public String getPbocBankCode() {
        return pbocBankCode;
    }
    public void setPbocBankCode(String pbocBankCode) {
        this.pbocBankCode = pbocBankCode;
    }
    public String getBankName() {
        return bankName;
    }
    public void setBankName(String bankName) {
        this.bankName = bankName;
    }
    public String getBankAcctNum() {
        return bankAcctNum;
    }
    public void setBankAcctNum(String bankAcctNum) {
        this.bankAcctNum = bankAcctNum;
    }
    public String getBankAcctName() {
        return bankAcctName;
    }
    public void setBankAcctName(String bankAcctName) {
        this.bankAcctName = bankAcctName;
    }
    public RequestType getRequestType() {
        return requestType;
    }
    public void setRequestType(RequestType requestType) {
        this.requestType = requestType;
    }
    public TranLimitRes getCustTranLimitConf() {
        return custTranLimitConf;
    }
    public void setCustTranLimitConf(TranLimitRes custTranLimitConf) {
        this.custTranLimitConf = custTranLimitConf;
    }
    public String getCustId() {
        return custId;
    }
    public void setCustId(String custId) {
        this.custId = custId;
    }
    public AcctProd getAcctProd() {
        return acctProd;
    }
    public void setAcctProd(AcctProd acctProd) {
        this.acctProd = acctProd;
    }
    public String getGopayOrderId() {
        return gopayOrderId;
    }
    public void setGopayOrderId(String gopayOrderId) {
        this.gopayOrderId = gopayOrderId;
    }
    public IntTxnCd getIntTxnCd() {
        return intTxnCd;
    }
    public void setIntTxnCd(IntTxnCd intTxnCd) {
        this.intTxnCd = intTxnCd;
    }
    public TranDirection getTranDirection() {
        return tranDirection;
    }
    public void setTranDirection(TranDirection tranDirection) {
        this.tranDirection = tranDirection;
    }
    public String getTransDate() {
        return transDate;
    }
    public void setTransDate(String transDate) {
        this.transDate = transDate;
    }
}